package com.wandian.texas.db;

import com.wandian.util.Log;
import com.wandian.util.TimeUtil;

/**
 * @author long
 * @Create 2012-10-8 上午9:59:14
 * @QQ 108232706
 * @version 1.0
 * @description DbWatch
 */
public class DbWatch {
	private long first = 0L;
	private long second = 0L;

	public DbWatch() {
	}

	public void start() {
		this.first = TimeUtil.getSysCurTimeMillis();
	}

	/**
	 * dao操作获取连接的时间
	 */
	public void getPool() {
		//		this.second = TimeUtil.getSysCurTimeMillis();
	}

	public void commit(String procName) {
		this.second = TimeUtil.getSysCurTimeMillis();
		long spendTime = this.second - this.first;
		if (spendTime > 1000L) {
			Log.error("执行语句" + procName + "花耗时间总时间 超过:" + spendTime + "ms");
		}
	}

	public long commit() {
		this.second = TimeUtil.getSysCurTimeMillis();
		return this.second - this.first;
	}
	//	private void commit0(String procName) {
	//		long end = TimeUtil.getSysCurTimeMillis();
	//		long spendTime = end - this.first;
	//		if (spendTime > 1000L) {
	//			Log.error(String.format("执行语句%s花耗时间总时间 超过:%sms,获取连接：%sms,执行sql:%sms", new Object[] { procName, Long.valueOf(spendTime), Long.valueOf(this.second - this.first), Long.valueOf(end - this.second) }));
	//			//			Log.error(/* "Log Pool:" + DBPoolMgr.getLogPoolState() + */"Wandian Pool:" + DBPoolMgr.getwandianPoolState());
	//		}
	//	}
}
